﻿using JESAI.Redis.Enums;
using System;
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;

namespace JESAI.Redis.Builders
{
    public class ConnectionStringBuilder
    {
        private string _Host = "127.0.0.1:6379";
        /// <summary>
        /// redis主机
        /// </summary>
        public string Host
        {
            get { return _Host; }
            set
            {
                if (!string.IsNullOrWhiteSpace(value))
                {
                    _Host = value.StartsWith("localhost", StringComparison.OrdinalIgnoreCase) ? Regex.Replace(value, "localhost", "127.0.0.1", RegexOptions.IgnoreCase) : value;
                }
            }
        }

        /// <summary>
        /// 注意:集群模式下，只有DB0数据库可用
        /// </summary>
        public int Database { get; set; } = 0;

        /// <summary>
        /// 最大连接数
        /// </summary>
        public int MaxPoolSize { get; set; } = 100;

        /// <summary>
        /// 最小连接数
        public int MinPoolSize { get; set; } = 1;

        /// <summary>
        /// 通信协议
        /// </summary>
        public RedisProtocolEnum Protocol { get; set; } = RedisProtocolEnum.RESP2;

        /// <summary>
        /// 客户端名称
        /// </summary>
        public string ClientName { get; set; }

        /// <summary>
        /// ???
        /// </summary>

        public string Prefix { get; set; }

    }
}
